home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / tools / xmstrix.com / HICOPY.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-11-02  |  3.0 KB  |  119 lines

  1. ;filename HICOPY.ASM - file to test copying of a block of
  2. ; data into the HMA from conventional memory
  3. ;Released into the Public Domain - November/88 by D. Roy
  4.  
  5. CODE        SEGMENT PARA PUBLIC 'CODE'
  6.         ASSUME    CS:CODE, DS:CODE ;-----------------------------;
  7.         ORG    100H         ;COM file format! Remember to ;
  8.                      ; use EXE2BIN                 ;
  9. START:                     ;-----------------------------;
  10.     JMP    XMSTEST
  11. ;data area
  12. COPY_CODE    LABEL    BYTE
  13.     SOURCE_DATA    DB    16 DUP ("DATA ")
  14. COPY_END    LABEL    BYTE
  15. XMSControl    DD    ?
  16.  
  17. NODRIVER_MSG    DB    'No XMS driver installed!...$'
  18. BADVERS_MSG    DB    'Requires Version 2.X XMS Driver!...$'
  19. NOHMA_MSG    DB    'HMA denied!...$'
  20. OKHMA_MSG    DB    'HMA successfully allocated!',10,13,'$'
  21. NOA20_MSG    DB    'A20 Line not enabled!$'
  22. A20LINE_MSG    DB    'A20 Line enabled...',10,13,'$'
  23. COPY_MSG    DB    'Copying...$'
  24. COMPLETE_MSG    DB    'complete.',10,13,'$'
  25.  
  26. ;code area
  27. XMSTEST:
  28.     MOV    AX,4300h
  29.     INT    2Fh
  30.     CMP    AL,80h
  31.     LEA    DX,NODRIVER_MSG
  32.     JNE    ERROR_EXIT
  33. ;get address of control driver function
  34.     MOV    AX,4310h
  35.     INT    2Fh
  36.     MOV    WORD PTR [XMSControl],BX
  37.     MOV    WORD PTR [XMSControl+2],ES
  38. ;get driver's version number
  39.     MOV    AH,00
  40.     CALL    [XMSControl]
  41.     CMP    AH,2
  42.     LEA    DX,BADVERS_MSG
  43.     JNE    ERROR_EXIT
  44. ;now request an HMA
  45.     MOV    AH,01
  46.     MOV    DX,80        ;16X5 bytes
  47.     CALL    [XMSControl]
  48. ;and verify allocation
  49.     OR    AX,AX
  50.     LEA    DX,NOHMA_MSG
  51.     JE    ERROR_EXIT
  52.     LEA    DX,OKHMA_MSG
  53.     CALL    WRITE_STRING
  54. ;now, enable the A20 address line
  55.     MOV    AH,3
  56.     CALL    [XMSControl]
  57.     OR    AX,AX
  58.     LEA    DX,NOA20_MSG
  59.     JE    ERROR_EXIT
  60.     LEA    DX,A20LINE_MSG
  61.     CALL    WRITE_STRING
  62. ;OK, let's do a block copy to the HMA
  63.     LEA    DX,COPY_MSG        ;say what we're up to
  64.     CALL    WRITE_STRING
  65.     CLD                ;direction forward
  66.     PUSH    SI            ;save what we're using
  67.     PUSH    DI
  68.     PUSH    ES
  69.     MOV    CX,OFFSET COPY_END    ;end of data
  70.     SUB    CX,OFFSET COPY_CODE    ;start of data
  71.     SHR    CX,1            ;divide by 2 for words
  72.     LEA    SI,COPY_CODE        ;point to source
  73.     MOV    BX,0FFFFh        ;segment of HMA
  74.     MOV    ES,BX            ; into ES
  75.     MOV    DI,0010h        ;point to offset
  76. L1:    MOVSW                ;moving words is faster
  77.     LOOP    L1            ;loop until done
  78.     POP    ES            ;housecleaning
  79.     POP    DI
  80.     POP    SI
  81. ;and signal completion
  82.     LEA    DX,COMPLETE_MSG
  83.     CALL    WRITE_STRING
  84. ;---------------------------------------------------------------------------
  85. ;The next four instructions reflect good housekeeping that any application
  86. ; should do on exiting. However, if we do this in this test program, you
  87. ; won't be able to use DEBUG to see the evidence of the successful block
  88. ; copy into the HMA. After checking the HMA with DEBUG, run the program
  89. ; HMACLEAR.COM to release our handiwork.
  90. ;
  91. ; DEBUG Instructions:
  92. ; 1) Run DEBUG
  93. ; 2) At the - prompt, type 
  94. ;    D FFFF:0010
  95. ;    and press <enter>
  96. ; 3) Type Q <enter> to return to DOS.
  97. ;--------------------------------------------------------------------------
  98. ;finally, disable the A20 address line
  99. ;    MOV    AH,4
  100. ;    CALL    [XMSControl]
  101. ;and release the HMA
  102. ;    MOV    AH,2
  103. ;    CALL    [XMSControl]
  104.     JMP    EXIT
  105. ERROR_EXIT:
  106.     CALL    WRITE_STRING
  107. EXIT:    INT    20h
  108.  
  109. ;-- subroutines ---------------
  110.  
  111. WRITE_STRING    PROC    NEAR
  112.     MOV    AH,9
  113.     INT    21h
  114.     RET
  115. WRITE_STRING    ENDP
  116.  
  117. CODE        ENDS
  118.     END    START
  119.